package com.tmsps.common.config;

import com.tmsps.common.config.prop.ExceptionCode;
import com.tmsps.common.exception.GlobalExceptionAdvice;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName GlobalExceptionAdviceAutoConfiguration
 * @description 自动注入全局异常处理器
 * @author geek
 * @date 2020年06月30日 14:33
 */
@EnableConfigurationProperties(ExceptionCode.class)
@Configuration
public class GlobalExceptionAdviceAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(value = GlobalExceptionAdvice.class)
    public GlobalExceptionAdvice globalExceptionAdvice(ExceptionCode exceptionCode){
        return new GlobalExceptionAdvice(exceptionCode);
    }
}
